package com.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.entity.pojo.LfLawyer;
import com.mapper.LfLawyerMapper;
import com.service.LawyerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

@Service("LawyerService")
public class LawyerServiceImp implements LawyerService {

    @Resource
    private LfLawyerMapper lfLawyerMapper;

    @Override
    public int insertLawyer(LfLawyer lfLawyer) {
        lfLawyer.setCreateTime(LocalDateTime.now());
        return lfLawyerMapper.insert(lfLawyer);
    }

    @Override
    public List<LfLawyer> listLawyer() {
        return lfLawyerMapper.selectList(new QueryWrapper<LfLawyer>().eq("deleted", 0));
    }

    @Override
    public int deleteLawyer(Integer id) {
        return lfLawyerMapper.updateById(new LfLawyer().setId(id).setDeleted(1).setUpdateTime(LocalDateTime.now()));
    }

    @Override
    public int updateLawyer(LfLawyer lawyer) {
        return lfLawyerMapper.updateById(lawyer.setUpdateTime(LocalDateTime.now()));
    }
}
